package hiWorld.amad.it;


import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.os.Bundle;
import android.widget.Toast;

public class gpsLog implements LocationListener {

	public static final String ACTION_REFRESH_GPS_COORDS = "it.amad.GPS_POLL";
	
/*	@Override
	public void onReceive(Context context, Intent intent) {
		// This method is invoked when the alarm is triggered
		
		//MainActivity.setCoords(0, 0);
	// 	MainActivity.updateCoords();
	
		Intent startIntent = new Intent(context, MainActivity.class);
		
		startIntent.setAction(ACTION_REFRESH_GPS_COORDS);
		
		context.startActivity(startIntent);
	}*/

	public void onLocationChanged(Location newLocation) {
    	Toast.makeText(MainActivity.myContext, "Now I'm @" +newLocation.getLongitude()+";"+newLocation.getLatitude(), Toast.LENGTH_LONG).show();
    	
    	Intent startIntent = new Intent(MainActivity.myContext, MainActivity.class);
		
		startIntent.setAction(ACTION_REFRESH_GPS_COORDS);
		startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		MainActivity.storeCoords((int)(newLocation.getLongitude()*1e6), (int)(newLocation.getLatitude()*1e6));
		
		MainActivity.myContext.startActivity(startIntent);
	}

	public void onProviderDisabled(String provider) {
		// TODO Auto-generated method stub

	}

	public void onProviderEnabled(String provider) {
		// TODO Auto-generated method stub

	}

	public void onStatusChanged(String provider, int status, Bundle extras) {
		// TODO Auto-generated method stub

	}

}
